package com.sanery.ui.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sanery.service.UserService;
import com.sanery.service.impl.UserServiceImpl;

@Controller
public class AjaxController {
	@RequestMapping(value = "/ajax/regname", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
	@ResponseBody
	public String regname(@RequestParam(required = true) String regname) {
		// 调用服务层查询数据库
		UserService service = new UserServiceImpl();
		Integer count = service.getUserCount(regname);
		String json = "{\"count\":" + count + "}";
		return json;
	}
}
